file transfer: Fix build on non-Linux
authorMatthias Clasen <mclasen@redhat.com>
Mon, 16 Dec 2019 16:28:21 +0000 (11:28 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 16 Dec 2019 16:38:04 +0000 (11:38 -0500)
O_PATH and O_CLOEXEC are not universally available.

gdk/filetransferportal.c

index 97e41346517ad7a6995c1e4c6d66b8967b3837b6..ff9c7996747b263000f7ea1ed4e8eb359c99c876 100644 (file)
 #include <gio/gio.h>
 #include <gio/gunixfdlist.h>
 
+#ifndef O_PATH
+#define O_PATH 0
+#endif
+
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#else
+#define HAVE_O_CLOEXEC 1
+#endif
+
 #include "filetransferportalprivate.h"
 
 static GDBusProxy *file_transfer_proxy = NULL;
@@ -158,6 +168,10 @@ add_files (GDBusProxy  *proxy,
           g_object_unref (fd_list);
           return;
          }
+
+#ifndef HAVE_O_CLOEXEC
+      fcntl (fd, F_SETFD, FD_CLOEXEC);
+#endif
       fd_in = g_unix_fd_list_append (fd_list, fd, &error);
       close (fd);